﻿
app.controller('PortalController', function ($scope, $http, $window, $compile, $filter, ipCookie, common, option, Upload) {
    $scope.result = {};
    $scope.dateOption = option.date;
    $scope.datetimeOption = option.datetime;

    $scope.ShowUserInfo = function () {
        $scope.PortalUser = JSON.parse(sessionStorage.getItem('PortalAccountInfo'));
    }
    $scope.Logout = function () {
        alertify.okBtn("确认")
            .cancelBtn("取消").confirm("确认退出当前账号？", function (ev) {
                ev.preventDefault();

                $http.post('../Account/Logout')
                    .success(function (ret) {
                        sessionStorage.removeItem("PortalAccountInfo");
                        sessionStorage.removeItem("PortalMenu");
                        sessionStorage.removeItem("LeftMenu");
                        $window.location.href = $window.location.href;
                    })
                    .error(function (data, status, headers, config) {

                    });

            }, function (ev) {
                ev.preventDefault();
            });
    }
    $scope.GetLeftMenu = function () {
        var menu = sessionStorage.getItem('LeftMenu');
        if (menu == null || menu == "") {
            $http({
                method: 'POST',
                url: '../Account/GetLeftMenu'
            })
                .success(function (ret) {
                    if (ret.Code == 100) {
                        $scope.MenuList = ret.Data;
                        sessionStorage.setItem("LeftMenu", JSON.stringify(ret.Data));
                    }
                    else {
                        alert(ret.Msg);
                    }
                })
                .error(function (data, status, headers, config) {
                });
        }
        else {
            $scope.MenuList = JSON.parse(menu);
        }
    }
    $scope.GetPortalMenu = function () {
        var menu = sessionStorage.getItem('PortalMenu');
        if (menu == null || menu == "") {
            $http({
                method: 'POST',
                url: '../SystemConfig/GetAllSystemMenu'
            })
                .success(function (ret) {
                    if (ret.Code == 100) {
                        $scope.PortalMenuList = ret.Data;

                        sessionStorage.setItem("PortalMenu", JSON.stringify(ret.Data));
                    }
                    else {
                        alert(ret.Msg);
                    }
                })
                .error(function (data, status, headers, config) {
                });
        }
        else {
            $scope.PortalMenuList = JSON.parse(menu);
        }
    }

    $scope.GetSystemEnterance = function () {
        $http({
            method: 'POST',
            url: '../SystemConfig/GetSystemEnterance'
        })
            .success(function (ret) {
                if (ret.Code == 100) {
                    $scope.enterances = ret.Data;
                }
                else {
                    alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
            });
    }

    $scope.GoPage = function (model) {
        if (model.Url == "" || model.Url == null) {
          return  alertify.alert("请选择下级菜单");
        }
        if (model.Url != "" && (model.Param == null || model.Param == '')) {
            return  window.open(model.Url, '_blank');
        }
        if (model.Url != "" && model.Param != null && model.Param != "") {
            $http({
                method: 'POST',
                url: '../Account/GetJwtToken'
            })
                .success(function (ret) {
                    if (ret.Code == 100) {

                        if (model.Param =='outer6s') {
                            $http({
                                method: 'POST',
                                url: '../Account/Get6SUrl'
                            }).success((res) => {
                                if (res?.Data) {
                                    window.open(res.Data, '_blank');
                                } else {
                                    alertify.alert('链接已失效，请联系管理员');
                                }
   
                            }).error(function (data, status, headers, config) {
                            });
                        } else {
                            var url = model.Url + "?" + model.Param + "&token=" + ret.Data;
                            window.open(url, '_blank');
                        }
                    }
                    else {
                        alertify.alert(ret.Msg);
                    }
                })
                .error(function (data, status, headers, config) {
                });
        }
        $scope.boxShow=false
    }

    $scope.GetSonList = function (node) {
        console.log(node.NodeList);
    }

    $scope.initpage = function () {
        $scope.show_riskchart();
        $scope.show_conschart();
        $scope.show_powerchart();
        $scope.show_safetyindex();
        $scope.show_safetyindex_score();
    }

    $scope.show_riskchart = function () {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('rishchart'));
        var option = {
            tooltip: {
                trigger: 'item'
            },
            legend: {
                top: '5%',
                left: 'left',
                icon: 'circle',
                textStyle: {
                    color: 'white' // 将图例字体颜色设置为白色  
                }
            },
            grid: {
                left: '20%', // 设置图表距离容器左侧的距离为10%  ..  
            },
            series: [
                {
                    name: 'Access From',
                    type: 'pie',
                    radius: ['40%', '75%'],
                    itemStyle: {
                        borderRadius: 1,
                        borderWidth: 2,
                        borderColor: 'rgb(4,24,59)',
                    },
                    center: ['35%', '60%'],
                    avoidLabelOverlap: false,
                    label: {
                        show: false,
                        position: 'center'
                    },
                    emphasis: {
                        label: {
                            show: true,
                            fontSize: 40,
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: false
                    },
                    data: [
                        { value: 60, name: '低' },
                        { value: 25, name: '一般' },
                        { value: 10, name: '较大' },
                        { value: 5, name: '重大' },
                    ],
                    color: ['rgb(0,182,255)', 'yellow', 'orange', 'red', '#91c7ae', '#749f83', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3']
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    $scope.show_conschart = function () {
        var total = 141;
        total = "141";
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('conschart'));
        var option = {
            tooltip: {
                trigger: 'item'
            },
            legend: {
                top: '5%',
                left: 'center',
                show: false
            },
            graphic:
            {
                type: 'text', // 创建一个文本元素  
                left: 'center', // 文本的位置  
                top: 'center',
                style: {
                    text: total, // 文本内容  
                    textBaseline: 'middle',
                    textAlign: 'center',
                    fill: 'white', // 文本颜色  
                    fontSize: 35 // 字体大小  
                },
            },
            series: [
                {
                    name: '作业占比',
                    type: 'pie',

                    radius: ['65%', '95%'],
                    itemStyle: {
                        borderRadius: 8,
                        borderWidth: 5,
                        borderColor: 'rgb(4,24,59)',
                    },
                    avoidLabelOverlap: false,

                    label: {
                        show: false,
                        position: 'center', // 将标签位置设置为饼图中心  
                        formatter: '{d}%', // 默认的格式化函数，这里可以替换为显示总数的逻辑  
                        rich: {
                            total: {
                                color: 'white', // 设置字体颜色  
                                fontSize: 25, // 设置字体大小  
                                align: 'center' // 设置对齐方式  
                            }
                        }
                    },
                    emphasis: {
                        label: {
                            show: false,
                            fontSize: 40,
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: false
                    },
                    data: [
                        { value: 100, name: '施工作业', itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgb(255, 175, 213)' }, { offset: 1, color: 'rgb(245, 105, 135)' }]) } },
                        { value: 15, name: '动火作业', itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgb(242, 195, 88)' }, { offset: 1, color: 'rgb(255, 225, 160)' }]) } },
                        { value: 20, name: '高处作业', itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgb(78, 255, 255)' }, { offset: 1, color: 'rgb(160, 252, 255)' }]) } },
                        { value: 8, name: '有限空间作业', itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgb(46, 179, 255)' }, { offset: 1, color: 'rgb(154, 223, 255)' }]) } },
                    ]

                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    $scope.show_powerchart = function () {
        var myChart = echarts.init(document.getElementById('powerchart'));
        var option = {
            title: {
                show: false,
                text: 'Stacked Area Chart'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    label: {
                        backgroundColor: '#6a7985'
                    }
                }
            },
            legend: {
                textStyle: {
                    color: 'white' // 设置图例字体颜色为深灰色  
                },
                padding: [0, 0, 0, 0],
                data: ['工业能耗', '环境排放']
            },
            toolbox: {
                show: false,
                feature: {
                    saveAsImage: {}
                }
            },
            grid: {
                top: "10%",
                left: '3%',
                right: '4%',
                bottom: '30%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    boundaryGap: false,
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                }
            ],
            yAxis:
            {
                name: "万吨标煤",
                type: 'value'
            }
            ,
            series: [
                {
                    name: '工业能耗',
                    type: 'line',
                    stack: 'Total',
                    areaStyle: {},
                    emphasis: {
                        focus: 'series'
                    },
                    showSymbol: false,
                    data: [120, 132, 101, 134, 90, 230, 210],
                    areaStyle: {
                        opacity: 0.8,
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                            {
                                offset: 0,
                                color: 'rgb(9, 58, 127,0.5)'
                            },
                            {
                                offset: 1,
                                color: 'rgb(0, 0, 0,0.9)'
                            }
                        ])
                    }
                },
                {
                    name: '环境排放',
                    type: 'line',
                    stack: 'Total',
                    areaStyle: {},
                    emphasis: {
                        focus: 'series'
                    },
                    showSymbol: false,
                    data: [220, 182, 191, 234, 290, 330, 310],
                    areaStyle: {
                        opacity: 0.8,
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                            {
                                offset: 0,
                                color: 'rgb(242, 152, 68,0.5)'
                            },
                            {
                                offset: 1,
                                color: 'rgb(0, 0, 0,0)'
                            }
                        ])
                    }
                }
            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    $scope.show_safetyindex = function () {
        var myChart = echarts.init(document.getElementById('safetyindex'));
        var xData2 = ["人员", "机械", "环境", "管理"];
        var data1 = [80, 70, 50, 70];
        var data2 = [100, 100, 100, 100];
        option = {

            tooltip: {
                trigger: 'item',
            },
            grid: {
                top: 100,
                left: 10,
                bottom: 15,
                right: 0
            },
            xAxis: {
                show: false,
                data: xData2,
                axisTick: {
                    show: false
                },
                axisLine: {
                    show: false
                },
                axisLabel: {
                    interval: 0,
                    textStyle: {
                        color: '#fff',
                        fontSize: 20,
                    },
                    margin: 20, //刻度标签与轴线之间的距离。
                },

            },
            yAxis: {
                show: false,
                splitLine: {
                    show: false,
                },
                axisTick: {
                    show: false
                },
                axisLine: {
                    show: false
                },
                axisLabel: {
                    textStyle: {
                        color: '#fff',
                        fontSize: 20,
                    },
                }
            },
            series: [
                {//三个最低下的圆片
                    "name": "",
                    "type": "pictorialBar",
                    "symbolSize": [45, 25],
                    "symbolOffset": [0, 10],
                    "z": 12,
                    itemStyle: {
                        opacity: 1,
                        color: function (params) {
                            var a = params.name.slice(0, 2);
                            if (a === '人员') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#FF9A22' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#FFD56E'// 100% 处的颜色
                                }], false)
                            } else if (a === '机械') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#00EC28' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#5DF076'// 100% 处的颜色
                                }], false)
                            } else if (a === '环境') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: 'rgb(89,95,235,0.9)' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: 'rgb(89,95,235,0.9)'// 100% 处的颜色
                                }], false)
                            }

                            else if (a === '管理') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#12B9DB' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#6F8EF2'// 100% 处的颜色
                                }], false)
                            }
                        }
                    },
                    "data": [1, 1, 1, 1, 1]
                },


                //下半截柱状图
                {
                    name: '2020',
                    type: 'bar',
                    barWidth: 45,
                    barGap: '-100%',
                    itemStyle: {//lenged文本
                        opacity: .7,
                        color: function (params) {
                            var a = params.name.slice(0, 2);
                            if (a === '人员') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#FF9A22' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#FFD56E'// 100% 处的颜色
                                }], false)
                            } else if (a === '机械') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#00EC28' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#5DF076'// 100% 处的颜色
                                }], false)
                            }
                            else if (a === '环境') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: 'rgb(89,95,235,0.9)' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: 'rgb(89,95,235,0.9)'// 100% 处的颜色
                                }], false)
                            } else if (a === '管理') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#12B9DB' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#6F8EF2'// 100% 处的颜色
                                }], false)
                            }
                        }
                    },

                    data: data1
                },

                { // 替代柱状图 默认不显示颜色，是最下方柱图（邮件营销）的value值 - 20
                    type: 'bar',
                    barWidth: 45,
                    barGap: '-100%',
                    stack: '广告',
                    itemStyle: {
                        color: 'transparent'
                    },
                    data: data1
                },

                {
                    "name": "", //头部
                    "type": "pictorialBar",
                    "symbolSize": [45, 25],
                    "symbolOffset": [0, -10],
                    "z": 12,
                    "symbolPosition": "end",
                    itemStyle: {
                        color: '#163F7A',
                        opacity: 1,
                    },
                    "data": data2
                },

                {
                    "name": "",
                    "type": "pictorialBar",
                    "symbolSize": [45, 25],
                    "symbolOffset": [0, -10],
                    "z": 12,
                    itemStyle: {
                        opacity: 1,
                        color: function (params) {
                            var a = params.name.slice(0, 2);
                            if (a === '人员') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#FF9A22' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#FFD56E'// 100% 处的颜色
                                }], false)
                            } else if (a === '机械') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#00EC28' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#5DF076'// 100% 处的颜色
                                }], false)
                            }
                            else if (a === '环境') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#5C50E5' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#4388FF'// 100% 处的颜色
                                }], false)
                            } else if (a === '管理') {
                                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                    offset: 0,
                                    color: '#12B9DB' // 0% 处的颜色
                                }, {
                                    offset: 1,
                                    color: '#6F8EF2'// 100% 处的颜色
                                }], false)
                            }
                        }
                    },
                    "symbolPosition": "end",
                    "data": data1
                },

                {
                    name: '2019',
                    type: 'bar',
                    barWidth: 45,
                    barGap: '-100%',
                    z: 0,
                    itemStyle: {
                        color: '#163F7A',
                        opacity: .7,
                    },

                    data: data2
                }


            ]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }


    $scope.show_safetyindex_score = function () {
        var myChart = echarts.init(document.getElementById('totalscore'));
        var option = {
            series: [{
                type: 'gauge',
                startAngle: 200,
                endAngle: -20,
                radius: '80%',
                min: 0,
                max: 100,
                splitNumber: 5,
                center: ['50%', '75%'],
                axisLine: {
                    distance: -60,
                    lineStyle: {
                        width: 4,
                        color: [
                            [0.8, 'red'],
                            [0.85, 'orange'],
                            [0.9, 'yellow'],
                            [1, 'green']
                        ]
                    }
                },
                pointer: {
                    icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
                    length: '86%',
                    width: 5,
                    offsetCenter: [0, '0%'],
                    itemStyle: {
                        color: 'auto'
                    }
                },
                axisTick: {
                    distance: 2,
                    length: 5,
                    lineStyle: {
                        color: 'white',
                        width: 2
                    }
                },
                axisLabel: {
                    color: 'white'
                },
                splitLine: {
                    length: 1,
                    lineStyle: {
                        color: 'white',
                        width: 2
                    }
                },

                title: {
                    offsetCenter: [0, '-20%'],
                    fontSize: 25,
                    textStyle: {
                        color: 'white'
                    }
                },
                detail: {
                    show: true,
                    fontSize: 22,
                    offsetCenter: [0, 45],
                    valueAnimation: true,
                    formatter: function (value) {
                        return value;
                    },
                    color: 'white'
                },
                data: [{
                    value: 95,
                    name: '优秀',
                    textStyle: {
                        color: 'green'
                    }
                }]
            }]
        };
        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });

    }










    ////////////////////////////////////////////////新闻模块/////////////////////////////////////////////////

    $scope.GetWorkContentList = function () {
        $scope.WorkContentList = [];
        $http({
            method: 'POST',
            url: '../NewsCenter/GetLastedNews',
            data: { "type": 1, "count": 7 }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.WorkContentList = ret.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                mui.toast("请检查网络");
            });
    }
    $scope.GetNoficationList = function () {
        $scope.NoficationList = [];
        $http({
            method: 'POST',
            url: '../NewsCenter/GetLastedNews',
            data: { "type": 2, "count": 7 }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.NoficationList = ret.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                mui.toast("请检查网络");
            });
    }

    $scope.GetSpecialCheck = function () {
        $scope.SpecialCheckList = [];
        $http({
            method: 'POST',
            url: '../NewsCenter/GetLastedNews',
            data: { "type": 3, "count": 7 }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.SpecialCheckList = ret.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                mui.toast("请检查网络");
            });
    }
    $scope.GetTrainingList = function () {
        $scope.TrainingList = [];
        $http({
            method: 'POST',
            url: '../NewsCenter/GetLastedNews',
            data: { "type": 4, "count": 7 }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.TrainingList = ret.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                mui.toast("请检查网络");
            });
    }
    $scope.Get6sCheckList = function () {
        $scope.CheckList6s = [];
        $http({
            method: 'POST',
            url: '../NewsCenter/GetLastedNews',
            data: { "type": 5, "count": 7 }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.CheckList6s = ret.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                mui.toast("请检查网络");
            });
    }
    $scope.GetMeetingList = function () {
        $scope.MeetingList = [];
        $http({
            method: 'POST',
            url: '../NewsCenter/GetLastedNews',
            data: { "type": 6, "count": 7 }
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.MeetingList = ret.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                mui.toast("请检查网络");
            });
    }
    $scope.go = function () {

        window.location.href = "../Performance/PerformanceMeansure";
    }

    $scope.GetNoticeType = function () {
        $scope.NoticeTypeList = [];
        $http({
            method: 'POST',
            url: '../Notice/GetNoticeType'
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.NoticeTypeList = ret.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                mui.toast("请检查网络");
            });
    }

    $scope.GoNewsCenter = function (model, type) {
        window.open("../NewsCenter/NewsDetail?Id=" + model.Id + "&type=" + type, "_blank");
    }

    $scope.cIndex = -1

    $scope.boxShow = false;
    $scope.menueList = [];

    $scope.initData = () => {

        $scope.menueList = res;
    }

    $scope.ChooseItemLeave = function () {
        ////$scope.boxShow = false
        $scope.boxShow = false
        //let boxs = document.querySelectorAll('.popBox')
        //let items = document.querySelectorAll('.menu_item')
        //boxs.forEach((e) => {
        //    e.style.display = 'none'
        //})
        //items.forEach((e) => {
        //   e.className = 'menu_item'
        //})
    }
    $scope.PortalMenuListSon=[]
    $scope.ChooseItem = function (index) {
        $scope.cIndex = index;
        $scope.boxShow = true;
        $scope.PortalMenuListSon = $scope.PortalMenuList.filter((e, i) => i == index) && $scope.PortalMenuList.filter((e, i) => i == index)[0]

        console.log($scope.PortalMenuListSon, ' $scope.PortalMenuListSon');
        //let items = document.querySelectorAll('.menu_item')
        //for (let i in items) {
        //    if (i == index) {
        //        items[i].className ='menu_item active'
        //    } else {
        //        items[i].className = 'menu_item'
        //    }
        //}
        //let boxs = document.querySelectorAll('.popBox')

        //boxs.forEach((e, i) => {
        //    if (i == index) {
        //        e.style.display = 'block'
        //    } else {
        //        e.style.display = 'none'
        //    }
        //})

    }
});

app.filter("HideText", function () {

    return function (input, length) {
        if (input != null && input.length > length) {
            return input.substr(0, length) + "..."
        }
        else {
            return input;
        }
    }

});